<head>
	<meta charset="utf-8">
	<title>千千万能工具箱-在线markdown主页</title>
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3419308738737930"
	     crossorigin="anonymous"></script>
		 <meta name="description" content="千千万能工具箱，在线markdown，markdown编辑器，云笔记">
		 <meta name="keywords" content="编辑器,markdown,IT_迁哥,云笔记">
		 <meta name="robots" content="index, follow">
		   
		 <meta name="author" content="IT_迁哥">
</head>
<link rel="stylesheet" href="../js/layx/layx.min.css" />
<script src="../js/layx/layx.min.js"></script>
<link rel="stylesheet" href="../js/editormd/css/editormd.css" />

<style>
	#ele {
		position: absolute;
		right: 3%;

		top: 2%;
		/* z-index: 99999999; */
	}
</style>

<div id="app" v-loading="globalShow" style="overflow-x: hidden;">
	<div id="md-editor">
		<textarea style="display:none;"></textarea>
	</div>
	<div style="position: fixed;width: 100%; bottom: 4%;">
	<el-row :gutter="20" >
		<el-col :span="3" :offset="9">
			<el-input v-model="pageInfo.name" placeholder="请填写笔记页面名称" :clearable="true"></el-input>
		</el-col>
		<el-col :span="12">
			<el-button type="primary" @click="saveOrUpdateMd()">提交笔记</el-button>
		</el-col>
	</el-row>
	</div>
	<br />
	<br />
	<div id="ele">
		<el-dropdown @command="openEvent">
			<span class="el-dropdown-link">
				{{userInfo.nickname}}<i class="el-icon-arrow-down el-icon--right"></i>
			</span>
			<el-dropdown-menu slot="dropdown">
				<el-dropdown-item icon="el-icon-plus" command="0">创建新笔记</el-dropdown-item>
				<el-dropdown-item icon="el-icon-plus" command="1">个人信息</el-dropdown-item>
				<el-dropdown-item icon="el-icon-circle-plus" command="2">我的笔记页面</el-dropdown-item>
				<el-dropdown-item icon="el-icon-circle-plus-outline" command="3">chatgpt助手</el-dropdown-item>
				<el-dropdown-item icon="el-icon-check" command="4">小文件工具</el-dropdown-item>
				<el-dropdown-item icon="el-icon-check" command="5">休闲音乐</el-dropdown-item>
	         	<el-dropdown-item icon="el-icon-check" command="6">白噪音放松</el-dropdown-item>
				<el-dropdown-item icon="el-icon-circle-check" command="7">退出登录</el-dropdown-item>
			</el-dropdown-menu>
		</el-dropdown>
	</div>
	<el-dialog title="我的笔记页面" :visible.sync="pageDig" :modal="false" :close-on-click-modal="false" top="5vh"
		v-loading="pageLoading">
		<el-row :gutter="20">
			<el-col :span="6">
				<div>
					<el-input v-model="query.name" maxlength="20" placeholder="请输入笔记名称" :clearable="true"></el-input>
				</div>
			</el-col>
			<el-col :span="6">
				<div>
					<el-select v-model="query.status" placeholder="请选择">
						<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</div>
			</el-col>

			<el-col :span="4" :offset="1">
				<div>
					<el-button type="primary" @click="pageSearch(1)">搜索</el-button>
				</div>
			</el-col>
		</el-row>

		<el-table :data="gridData" style="height: 70%;">
			<el-table-column property="name" label="名称" width="150">
				<template slot-scope="scope">
					<span style="color: lightslategray;">{{ scope.row.name }}</span>
				</template>

			</el-table-column>
			<el-table-column property="timeDesc" label="时间" width="100">
				<template slot-scope="scope">
					<span style="color: lightslategray;">{{ scope.row.timeDesc }}</span>
				</template>

			</el-table-column>
			<el-table-column property="status" label="状态" width="100">
				<template slot-scope="scope">
					<el-tag type="info" v-if="scope.row.status==0">个人私有</el-tag>
					<el-tag type="success" v-if="scope.row.status==1">全网公开</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="操作栏" width="400">

				<template slot-scope="scope">
					<el-button type="danger" title="删除笔记页面" v-if="scope.row.status==0" @click="del(scope.row.id)">删除
					</el-button>
					<el-button type="success" v-if="scope.row.status==0" title="全网公开发布笔记页面"
						@click="online(scope.row.id,scope.row.publishUri,scope.row.mdUrl)">发布</el-button>
					<el-button type="info" v-if="scope.row.status==1" title="下架已经发布的笔记页面"
						@click="offline(scope.row.id,scope.row.publishUri)">下架</el-button>
					<el-button type="warning" v-if="scope.row.status==1" title="预览发布的笔记页面"
						@click="readView(scope.row.publishUri)">预览</el-button>
					<el-button type="primary" title="载入笔记页面编辑器进行编辑" @click="getPageInfo(scope.row.id)">载入</el-button>
					<el-button v-if="scope.row.status==1" title="复制发布的链接" @click="copyHtmlUrl(scope.row.publishUri)">复制
					</el-button>

				</template>
			</el-table-column>
		</el-table>
		<el-pagination @current-change="mdCurrentPage" layout="prev, pager, next,total" :background="true"
			:page-size="8" :current-page.sync="query.page" :total="total">
		</el-pagination>
	</el-dialog>


	<el-dialog title="发布配置"  width="30%":visible.sync="onlineDig" :modal="false" :close-on-click-modal="false" top="15vh"
>
	<el-row :gutter="20">
		<el-col :span="5"  style="margin-top: 1%;">
		<span>网页标题</span>
		</el-col>
		<el-col :span="14">
			<el-input v-model="onlineConfig.title" autocomplete="off" placeholder="请输入网页标题(最多20字)" maxlength="20" :clearable="true"></el-input>
		</el-col>
	</el-row>
		<br>
	<el-row :gutter="20">
		<el-col :span="5"  style="margin-top: 1%;">
	<span>	seo作者</span>
		</el-col>
		<el-col :span="14">
			<el-input v-model="onlineConfig.seoAuthor" autocomplete="off" placeholder="请输入seo作者(最多10字)" maxlength="10" :clearable="true"></el-input>
		</el-col>
	</el-row>
		<br>
	<el-row :gutter="20">
		<el-col :span="5" style="margin-top: 1%;" >
		<span >seo描述</span>
		</el-col>
		<el-col :span="14">
			<el-input v-model="onlineConfig.seoDescription" autocomplete="off"
			placeholder="请输入seo描述(最多50字)" maxlength="50" :clearable="true"></el-input>
		</el-col>
	</el-row>
	<br>
	<el-row :gutter="20">
		<el-col :span="5"  style="margin-top: 1%;">
		<span>seo关键词</span>
		</el-col>
		<el-col :span="14">
			<el-input :clearable="true" v-model="onlineConfig.seoKeywords" placeholder="请输入seo关键词(最多20字)" autocomplete="off" maxlength="20"></el-input>
		</el-col>
	</el-row>
	<br>

	<el-row :gutter="20">
		<el-col :span="5"  >
		<span>水印设置</span>
		</el-col>
		<el-col :span="14" style="margin-top: 1%;">
			<el-switch
			  v-model="onlineConfig.watermark"
			  active-text="有水印"
			  inactive-text="无水印">
			</el-switch>
		</el-col>
	</el-row>
	<br>
	<br>
	<el-row :gutter="20" v-if="onlineConfig.watermark">
		<el-col :span="5"  style="margin-top: 1%;">
		<span>水印内容</span>
		</el-col>
		<el-col :span="14">
			<el-input v-model="onlineConfig.watermarkText" placeholder="请输入水印内容(最多10字)" autocomplete="off" maxlength="10"></el-input>
		</el-col>
	</el-row>

	
	
  <div slot="footer" class="dialog-footer">
    <el-button @click="onlineDig = false">取 消</el-button>
    <el-button type="primary" @click="okOnline()">确 定</el-button>
  </div>
		
	</el-dialog>
	
	
	<el-dialog title="个人信息"  width="30%":visible.sync="userInfoDig" :modal="false" :close-on-click-modal="false" top="15vh"
	>
		<el-row :gutter="20">
			<el-col :span="5"  style="margin-top: 1%;">
			<span>昵称</span>
			</el-col>
			<el-col :span="14">
				<el-input v-model="userInfo2.nickname" autocomplete="off" placeholder="请输入昵称" maxlength="10" :clearable="true"></el-input>
			</el-col>
		</el-row>
			<br>
		<el-row :gutter="20">
			<el-col :span="5"  style="margin-top: 1%;">
		<span>	邮箱</span>
			</el-col>
			<el-col :span="14">
				<el-input :disabled="true" v-model="userInfo2.email" autocomplete="off"   :clearable="true"></el-input>
			</el-col>
		</el-row>
			<br>
		<el-row :gutter="20">
			<el-col :span="5" style="margin-top: 1%;" >
			<span >注册时间</span>
			</el-col>
			<el-col :span="14">
				<el-input :disabled="true" v-model="userInfo2.createTime" autocomplete="off"
				 :clearable="true"></el-input>
			</el-col>
		</el-row>
		<br>
		<el-row :gutter="20">
			<el-col :span="5"  :disabled="true" style="margin-top: 1%;">
			<span>最近登录</span>
			</el-col>
			<el-col :span="14">
				<el-input :clearable="true" :disabled="true" v-model="userInfo2.lastLoginTime" placeholder="请输入seo关键词(最多20字)" autocomplete="off" maxlength="20"></el-input>
			</el-col>
		</el-row>
	
	
	
		
		
	  <div slot="footer" class="dialog-footer">
	    <el-button @click="userInfoDig = false">取 消</el-button>
	    <el-button type="primary" @click="updateUserInfo()">确 定</el-button>
	  </div>
			
		</el-dialog>
</div>

<link rel="stylesheet" href="../js/element2.4.7/index.css" />
<script src="../js/vue2.6.11/vue.js"></script>
<script src="../js/element2.4.7/index.js"></script>
<script src="../js/jquery.min.js"></script>
<script src="../js/editormd/editormd.min.js"></script>
<script src="../js/aliyun-oss-sdk.min.js"></script>
<script src="template.js"></script>

<script type="text/javascript">
	
	const baseUrl = "https://api.lqcpws.cn"
	const app = new Vue({
		el: '#app',
		data: {
			pageInfo: {
				id: "",
				name: "",
				mdUrl: "",
				status: 0,


			},
			onlineConfig:{
				seoDescription:"",
				seoKeywords:"",
				seoAuthor:"",
				title:"",
				mdText:"",
				watermark:false,
				watermarkText:"",
			},
			onlineDig:false,
			globalShow: false,
			userInfoDig:false,
			userInfo: {
				email:"",
				createTime:"",
				nickname:"",
				lastLoginTime:"",
				
			},
			userInfo2: {
				email:"",
				createTime:"",
				nickname:"",
				lastLoginTime:"",
				
			},
			title: 'mark',
			editor: undefined,
			stsInfo: undefined,
			client: undefined,
			userDir: '/md',
			drawer: false,
			direction: "rtl",
			pageDig: false,
			pageLoading: false,
			query: {
				name: "",
				status: '-1',
				page: 1,
				limit:8
			},
			options: [{
				value: '-1',
				label: '全部'
			}, {
				value: '0',
				label: '个人私有'
			}, {
				value: '1',
				label: '全网公开'
			}],
			gridData: [],
			total: 0,
			onlineBaseUrl: 'https://www.lqcpws.cn/',
			refreshStsTime:1000*1200,
		},
		mounted() {
			debugger
	
			setInterval(function(that){
				// console.log('自动刷新')
			that.loadStsInfo()
			},this.refreshStsTime,this)
			this.$notify({
				title: '温馨提示',
				message: '1：ctrl+f 编辑器搜索<br/>' +
					'2：ctrl+shift+r 编辑器全局替换<br/>' +
					'3：发布的链接是唯一的<br/>' +
					'4：如果好用，请告诉你的朋友<br/>'+
					'5：编辑器的问号图标有markdown的使用说明<br/>'+
					'6：如果你要上传图片，请使用小文件工具<br/>',
				dangerouslyUseHTMLString: true,
				duration: 30000,
				type: 'warning'
			});
			
			
			this.getLastMdPage()
			this.loadStsInfo()
			this.checkStatus()
			this.getUserInfo()
			// console.log(this.getHtmlSign())

		},
		methods: {
			updateUserInfo(){
				if(this.userInfo2.nickname.trim()==""){
					this.$notify({
						title: '警告',
						message: '昵称不能为空！',
						duration: 2000,
						type: 'error'
					});  
					return;
				}
				let _this=this
				_this.globalShow = true
				$.ajax({
					type: 'post',
					url: baseUrl + '/md/mdUser/updateUserInfo',
					headers: {
						"md-token": localStorage.getItem("mdToken")
					},
					data:{nickname:_this.userInfo2.nickname},
					success(res) {
						_this.globalShow = false
						_this.ajaxRep(res)
						if (res.code == 200) {
							_this.userInfoDig=false
					    _this.$notify({
					    	title: '提示',
					    	message: '更新个人信息完成',
					    	duration: 2000,
					    	type: 'success'
					    });  
						}
				
					}
				})
			},
			del(id) {
				     this.$confirm('此操作将删除该笔记并刷新系统, 是否继续?', '警告', {
				          confirmButtonText: '确定',
				          cancelButtonText: '取消',
				          type: 'warning'
				        }).then(() => {
				       let _this = this
				       _this.globalShow = true
				       $.ajax({
				       	type: 'get',
				       	url: baseUrl + '/md/mdPage/removeMdPage',
				       	headers: {
				       		"md-token": localStorage.getItem("mdToken")
				       	},
				       	data:{id:id},
				       	success(res) {
				       		_this.globalShow = false
				       		_this.ajaxRep(res)
				       		if (res.code == 200) {
				       	     window.location.reload()
				       		}
				       
				       	}
				       })
				        }).catch(() => {
				  this.$notify({
				  	title: '提示',
				  	message: '已取消删除',
				  	duration: 2000,
				  	type: 'success'
				  });     
				        });
				
				
        
			},
			online(id,url,mdUrl) {
		
				this.onlineDig=true
				this.onlineConfig={
					id:id,
					mdUrl:mdUrl,
					url:url,
				seoDescription:"千千万能工具",
				seoKeywords:"千千万能工具",
				seoAuthor:"千千万能工具",
				title:"千千万能工具-在线markdown",
				mdText:"",
				watermark:false,
				watermarkText:"",
			}
			
			


			},
			okOnline(){
				let fileName=this.getHtmlSign()
				if(this.onlineConfig.url!=null&&this.onlineConfig.url.trim()!=""){
					fileName=this.onlineConfig.url.substring(this.onlineConfig.url.lastIndexOf("/")+1,this.onlineConfig.url.lastIndexOf("."))
		
		
				}
				let _this=this
				this.globalShow=true
			   _this.onlineConfig.mdText= _this.onlineConfig.mdUrl
				
				// console.log(this.onlineConfig)
				
				let data=this.dynicTemplate(templateStr,this.onlineConfig)
				this.putHtmlFile(fileName,data).then(htmlUrl=>{
					if(htmlUrl==""){
						this.$notify({
							title: '警告',
							message: '发布失败！请重试！',
							duration: 2000,
							type: 'error'
						});
						return;
					}
					$.ajax({
						type: 'post',
						url: baseUrl + '/md/mdPage/onlineOrOffLineMdPage',
						headers: {
							"md-token": localStorage.getItem("mdToken")
						},
						data:{id:_this.onlineConfig.id,status:1,onlineUrl:htmlUrl},
						success(res) {
							_this.globalShow = false
							_this.ajaxRep(res)
							if (res.code == 200) {
								_this.$notify({
									title: '提示',
									message: '发布成功！',
									duration: 2000,
									type: 'success'
								});
						     _this.onlineDig=false
							 _this.pageSearch(0)
							}
					
						}
					})
					
					
					
				})
			
			},
			dynicTemplate(str,obj){
				let newStr=str
				let keys=Object.keys(obj)
				
				keys.forEach(item=>{
	// console.log("{{"+item+"}}",obj.mdText)
					newStr=newStr.replaceAll("{{"+item+"}}",obj[item])
					
				})
				
				return newStr;
			},
			offline(id,url) {
				
				this.$confirm('此操作将全网下架该文章，会无法访问，是否继续?', '警告', {
				        confirmButtonText: '确定',
				        cancelButtonText: '取消',
				        type: 'warning'
				      }).then(() => {

	this.globalShow = true
				let _this=this
				this.deleteFile(url).then(flag=>{
					if(!flag){
						this.$notify({
							title: '警告',
							message: '下架失败，请重试！',
							duration: 2000,
							type: 'error'
						});
						return;
					}
					
					$.ajax({
						type: 'post',
						url: baseUrl + '/md/mdPage/onlineOrOffLineMdPage',
						headers: {
							"md-token": localStorage.getItem("mdToken")
						},
						data:{id:id,status:0,onlineUrl:""},
						success(res) {
							_this.globalShow = false
							_this.ajaxRep(res)
							if (res.code == 200) {
								_this.$notify({
									title: '提示',
									message: '下架成功！',
									duration: 2000,
									type: 'success'
								});
							 _this.pageSearch(0)
							}
					
						}
					})
					
				})
				
				      }).catch(() => {
				this.$notify({
					title: '提示',
					message: '已取消下架',
					duration: 2000,
					type: 'success'
				});     
				      });
				
				
				
			
		       
		

			},
			readView(url) {
				layx.destroy('new-window999')
				layx.open({
					id: 'new-window999',
					title: '预览发布页面',
					url: this.onlineBaseUrl+url,
					type: 'url'
				});
			},
			getPageInfo(id) {
			let _this = this
			_this.globalShow = true
			$.ajax({
				type: 'get',
				url: baseUrl + '/md/mdPage/getMdPage',
				headers: {
					"md-token": localStorage.getItem("mdToken")
				},
				data:{id:id},
				success(res) {
					_this.globalShow = false
					_this.ajaxRep(res)
					if (res.code == 200) {
			
				
							_this.pageInfo = res.data
							$.ajax({
								async: false,
								type: 'get',
								url: _this.pageInfo.mdUrl,
								success: function(res) {
									_this.editor.setMarkdown(res)
									_this.$notify({
										title: '提示',
										message: '载入笔记成功！',
										duration: 2000,
										type: 'success'
									});
								}
							})
						
					}
			
				}
			})

			},
			copyHtmlUrl(url) {

				// 创建一个临时的textarea元素
				var textarea = document.createElement('textarea');

				// 设置textarea的值为要复制到剪贴板的文本
				textarea.value = this.onlineBaseUrl+url;

				// 将textarea设为不可见
				textarea.style.position = 'fixed';
				textarea.style.top = '-9999px';

				// 将textarea添加到文档中
				document.body.appendChild(textarea);

				// 选中textarea中的文本
				textarea.select();

				// 执行复制命令
				document.execCommand('copy');

				// 删除临时的textarea元素
				document.body.removeChild(textarea);
				this.$notify({
					title: '提示',
					message: '复制链接成功！',
					duration: 2000,
					type: 'success'
				});
			},
			getLastMdPage() {
				let _this = this
				_this.globalShow = true
				$.ajax({
					type: 'get',
					url: baseUrl + '/md/mdPage/getLastMdPage',
					headers: {
						"md-token": localStorage.getItem("mdToken")
					},
					success(res) {
						_this.globalShow = false
						_this.ajaxRep(res)
						if (res.code == 200) {

							if (res.data == undefined) {
								_this.pageInfo = {
									id: "",
									name: "",
									mdUrl: "",
									status: 0,


								}
								_this.loadMarkdown("")
							} else {
								_this.pageInfo = res.data
								$.ajax({
									async: false,
									type: 'get',
									url: _this.pageInfo.mdUrl,
									success: function(res) {
										_this.loadMarkdown(res)
									}
								})
							}
						}

					}
				})
			},
			saveOrUpdateMd() {
				let data = this.editor.getMarkdown()
				if (data == undefined || data.trim() == "") {
					this.$notify.error({
						title: '警告',
						message: '笔记内容不能为空！',
						duration: 2000,
					});
					return;
				}
				if (this.pageInfo.name == undefined || this.pageInfo.name.trim() == "") {
					this.$notify.error({
						title: '警告',
						message: '笔记名称不能为空！',
						duration: 2000,
					});
					return;
				}
				let status = this.pageInfo.id == "";
				if (status) {
					this.pageInfo.id = this.getNewId()
				}
				this.globalShow = true;
				let _this = this
				this.putMdFile(this.pageInfo.id, data).then(mdUrl => {
					if (mdUrl == "") {
						_this.$notify.error({
							title: '警告',
							message: '保存笔记失败！',
							duration: 2000,
						});
						return;
					}
					_this.pageInfo.mdUrl = _this.onlineBaseUrl + mdUrl

					$.ajax({
						type: 'post',
						url: baseUrl + '/md/mdPage/saveOrUpdateMdPage?status=' + status,
						headers: {
							"md-token": localStorage.getItem("mdToken")
						},
						data: JSON.stringify(_this.pageInfo),
						contentType: 'application/json',
						success(res) {
							_this.globalShow = false
							_this.ajaxRep(res)
							if (res.code == 200) {
								_this.$notify({
									title: '提示',
									message: '保存笔记成功！',
									duration: 2000,
									type: 'success'
								});
							}

						}
					})
				})



			},
			getNewId() {
				var timestamp = new Date().getTime();
				var randomId = Math.random().toString(36).substr(2, 12);
				return this.userInfo.id + timestamp + randomId
			},
			getHtmlSign() {
				var timestamp = new Date().getTime();
				var randomId = Math.random().toString(36).substr(2, 16);
				return timestamp.toString().substr(0, 5) + randomId + timestamp.toString().substr(6)
			},
			logout() {
				let _this = this
				$.ajax({
					type: 'post',
					url: baseUrl + '/md/mdUser/logout',
					headers: {
						"md-token": localStorage.getItem("mdToken")
					},
					success(res) {
						_this.ajaxRep(res)
						if (res.code == 200) {
							localStorage.removeItem("mdToken")
							window.location.href = 'index.html'
						}
					}
				})
			},
			getUserInfo(status) {
				let _this = this
				$.ajax({
					type: 'get',
					url: baseUrl + '/md/mdUser/getMdUserInfo',
					headers: {
						"md-token": localStorage.getItem("mdToken")
					},
					success: function(res) {
						_this.ajaxRep(res)
						if (res.code == 200) {
							_this.userInfo = res.data
							_this.userInfo2={...res.data}
							if(status==undefined){
							_this.userDir = _this.userDir + "/" + _this.userInfo.id
							}
						}
					}


				})
			},
			ajaxRep(res) {
				if (res.code == 401) {
					this.$alert(res.msg, '未登录', {
						confirmButtonText: '确定',
						callback: action => {
							localStorage.removeItem("mdToken")
							window.location.href = 'index.html'
						}
					});
				}
				if (res.code == 500) {
					this.$notify.error({
						title: '警告',
						message: res.msg != undefined ? res.msg : "未知错误",
						duration: 2000,
					});
				}

			},
			pageSearch(type) {
				if (type == 1) {
					this.page = 1
				}
				this.pageLoading = true
				let _this = this
				$.ajax({
					type: 'get',
					url: baseUrl + '/md/mdPage/getMdPageForPage',
					headers: {
						"md-token": localStorage.getItem("mdToken")
					},
					data: this.query,
					success(res) {
						_this.ajaxRep(res)
						_this.pageLoading = false
						if (res.code == 200) {
							_this.total = res.total
							_this.gridData = res.data
						}
					}

				})
			},
			mdCurrentPage(page) {
				// console.log(page)
				// console.log(this.query.page)
				this.pageSearch(0)
			},
			handleClose(done) {
				done()
			},
			openEvent(command) {
				// console.log("open", command)
				if(command==0){
					this.pageInfo={
				id: "",
				name: "",
				mdUrl: "",
				status: 0,


			}
	
			this.editor.clear()
				}
				if(command==1){
					this.getUserInfo(1)
					this.userInfoDig=true
				}
				if(command==4){
					layx.destroy('new-window' + command)
					layx.open({
						id: 'new-window' + command,
						title: '小文件工具',
						url: '../tinyfile/',
						type: 'url'
					});
				}
				if (command == 5) {
					layx.destroy('new-window' + command)
					layx.open({
						id: 'new-window' + command,
						title: '休闲音乐',
						url: 'https://tool.liumingye.cn/music/',
						type: 'url'
					});
				}
				if (command == 3) {
					layx.destroy('new-window' + command)
					layx.open({
						id: 'new-window' + command,
						title: 'chatgpt助手',
						url: 'https://chat18.aichatos.xyz/#/chat/1698630311930',
						type: 'url'
					});
				}
				if (command == 2) {
					this.pageDig = true
					this.query.page = 1
					this.query.name = ""
					this.query.status = '-1'
					this.pageSearch(0)
				}
				if (command == 6) {
					layx.destroy('new-window' + command)
					layx.open({
						id: 'new-window' + command,
						title: '白噪音放松',
						url: 'https://www.rainymood.com/',
						type: 'url'
					});
				}

				if (command == 7) {
					this.logout()
				}
			},
			checkStatus() {
				window.addEventListener('beforeunload', function(e) {
					// console.log(e)
				    // 自定义提示消息
				    var confirmationMessage = '可能有未保存的内容，确定要关闭页面吗？';

				    // 设置提示消息（仅在部分浏览器中生效）
				    e.returnValue = confirmationMessage;

				    // 返回提示消息（适用于大多数浏览器）
				    return confirmationMessage;
				});
				const mdToken = localStorage.getItem("mdToken")
				if (mdToken == undefined || mdToken == "") {
					window.location.href = "index.html"
				}

			},

			loadMarkdown(data) {
				this.editor = editormd("md-editor", {
					width: "75%",
					height: "90%",
					path: "../js/editormd/lib/",
					autoFocus: true, // 自动聚焦
					toolbarAutoFixed: true, // 工具栏固定
					markdown: data == undefined ? "" : data, // 初始内容
					placeholder: "写点什么吧",
					saveHTMLToTextarea: true,
					emoji: true,
					searchReplace: true,
					codeFold: true,
					toc: true,
					taskList: true,
					tocm: true, // Using [TOCM]
					tex: true, // 开启科学公式TeX语言支持，默认关闭
					flowChart: true, // 开启流程图支持，默认关闭
					sequenceDiagram: true,
				});
// console.log(this.editor)

			},
			loadStsInfo() {
				let _this = this
				$.ajax({
					type: 'post',
					url: baseUrl + '/aliYun/sts/getOssStsInfo',
					success(res) {
						_this.stsInfo = res.data;
						_this.client = new OSS({
							// yourRegion填写Bucket所在地域。以华东1（杭州）为例，Region填写为oss-cn-hangzhou。
							region: 'oss-cn-shanghai',
							// 从STS服务获取的临时访问密钥（AccessKey ID和AccessKey Secret）。
							accessKeyId: res.data.accessKeyId,
							accessKeySecret: res.data.accessKeySecret,
							// 从STS服务获取的安全令牌（SecurityToken）。
							stsToken: res.data.securityToken,
							refreshSTSToken: async () => {
								// 向您搭建的STS服务获取临时访问凭证。
								const info = await fetch(url);
								return {
									accessKeyId: info.data.accessKeyId,
									accessKeySecret: info.data.accessKeySecret,
									stsToken: info.data.securityToken
								}
							},
							// 刷新临时访问凭证的时间间隔，单位为毫秒。
							refreshSTSTokenInterval: 1800000,
							// 填写Bucket名称。
							bucket: 'qq-gjx-pc'
						});
						// console.log(_this.client)
					}
				})
			},
			async putHtmlFile(fileName, text) {
				const data = new Blob([text]);
				try {
					// 填写Object完整路径。Object完整路径中不能包含Bucket名称。
					// 您可以通过自定义文件名（例如exampleobject.txt）或文件完整路径（例如exampledir/exampleobject.txt）的形式实现将数据上传到当前Bucket或Bucket中的指定目录。
					// data对象可以自定义为file对象、Blob数据或者OSS Buffer。
					const options = {
						headers: {
							"Content-Type": "text/html; charset=UTF-8"
						},
					};
					const result = await this.client.put(this.userDir + "/html/" + fileName + ".html", data,
						options);
					// console.log('putHtmlFile', result);
					return result.name

				} catch (e) {
					// console.log('putHtmlFile', e);
					return ""

				}
			},
			async putMdFile(fileName, text) {
				const data = new Blob([text]);
				try {
					// 填写Object完整路径。Object完整路径中不能包含Bucket名称。
					// 您可以通过自定义文件名（例如exampleobject.txt）或文件完整路径（例如exampledir/exampleobject.txt）的形式实现将数据上传到当前Bucket或Bucket中的指定目录。
					// data对象可以自定义为file对象、Blob数据或者OSS Buffer。
					const options = {
						headers: {
							"Content-Type": "text/markdown; charset=UTF-8"
						},
					};
					const result = await this.client.put(this.userDir + "/markdown/" + fileName + ".md", data,
						options);
					// console.log('putMdFile', result);
					// console.log(result.name)
					return result.name

				} catch (e) {
					// console.log('putMdFile', e);
					return ""

				}
			},
			async deleteFile(name) {
				try {
					let result = await this.client.delete(name);
					// console.log('deleteFile', result);

                  return true;
				} catch (e) {
                  return false;
				}
			}

		}
	})
</script>
